package com.ricky.onlineShop.serviceBus.trading;

import com.ricky.common.utils.DateUtils;
import com.ricky.onlineShop.read.trading.service.TradingReadService;
import com.ricky.onlineShop.shop.trading.pojo.Trading;
import com.ricky.onlineShop.shop.trading.service.ITradingService;
import com.ricky.onlineShop.shop.trading.vo.TradingVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author staticlan
 * @Date 2024/6/20 15:54
 * @Description:
 */
@Service
@Transactional(rollbackFor = RuntimeException.class)
public class TradingServiceBus {
    @Autowired
    private ITradingService tradingService;

    @Autowired
    private TradingReadService tradingReadService;


    public Trading saveInfo(TradingVo tradingVo) {
        return tradingService.saveInfo(tradingVo);
    }



    /**
     * 查询trading
     *
     * @param id trading主键
     * @return trading
     */
    public TradingVo selectTradingById(String id) {
        return tradingService.selectTradingById(id);
    }

    public boolean tradingAuction(String id){
        return tradingService.tradingAuction(id);
    }

    /**
     * 查询trading列表
     *
     * @param trading trading
     * @return trading
     */
    public List<Trading> selectTradingList(Trading trading)
    {
        return tradingReadService.selectTradingList(trading);
    }

    /**
     * 查询trading列表
     *
     * @param trading trading
     * @return trading
     */
    public List<Trading> selectMyTradingList(Trading trading)
    {
        return tradingReadService.selectMyTradingList(trading);
    }

    /**
     * 新增trading
     *
     * @param trading trading
     * @return 结果
     */
    public int insertTrading(Trading trading)
    {
        trading.setCreateTime(DateUtils.getNowDate());
        return tradingReadService.insertTrading(trading);
    }

    /**
     * 修改trading
     *
     * @param tradingVo tradingVo
     * @return 结果
     */
    public Trading updateTrading(TradingVo tradingVo) {
        return tradingService.updateTrading(tradingVo);
    }

    /**
     * 批量删除trading
     *
     * @param ids 需要删除的trading主键
     * @return 结果
     */
    public int deleteTradingByIds(String[] ids)
    {
        return tradingReadService.deleteTradingByIds(ids);
    }

    /**
     * 删除trading信息
     *
     * @param id trading主键
     * @return 结果
     */
    public int deleteTradingById(String id)
    {
        return tradingReadService.deleteTradingById(id);
    }

    public int myTradings(){
        return tradingReadService.myTradings();
    }
}
